package com.ali.config;

import lombok.extern.slf4j.Slf4j;

import java.lang.reflect.Method;

/**
 * 自定义注解处理器
 */
@Slf4j
public class MyAnnotationHandler {
    public static Object invokeMethod(Object object, Method method) {
        try {
            //判断方法是否包含注解
            if (method.isAnnotationPresent(TestAnnotation.class)) {
                //获取注解对象
                TestAnnotation testAnnotation = method.getAnnotation(TestAnnotation.class);
                log.info("注解内容：" + testAnnotation.value());
            }
            return method.invoke(object);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}